﻿using System;

namespace _03.CompareTwoCharArraysLetterByLetter
{
    class CompareTwoCharArraysLetterByLetter
    {
        static void Main()
        {
            Console.Write("Enter lenght of arrays:");
            Console.WriteLine("Lenght of first array:");
            int lenghtOfFirstArray = int.Parse(Console.ReadLine());
            Console.WriteLine("Lenght of second array:");
            int lenghtOfSecondArray = int.Parse(Console.ReadLine());
            char[] firstArray = new char[lenghtOfFirstArray];
            char[] secondArray = new char[lenghtOfSecondArray];
            Console.WriteLine("Enter elements of first array.The elements must be characters.");
            for (int i = 0; i < lenghtOfFirstArray; i++)
            {
                firstArray[i] = char.Parse(Console.ReadLine());
            }
            Console.WriteLine("Enter elements of second array.The elements must be characters.");
            for (int i = 0; i < lenghtOfSecondArray; i++)
            {
                secondArray[i] = char.Parse(Console.ReadLine());
            }
            int minLenght = Math.Min(lenghtOfFirstArray, lenghtOfSecondArray);
            bool equal = true;
            for (int i = 0; i < minLenght; i++)
            {
                if (firstArray[i] < secondArray[i])
                {
                    equal = false;
                    Console.WriteLine("First array is lexicographically first");
                    break;
                }
                else
                {
                    if (firstArray[i] > secondArray[i])
                    {
                        equal = false;
                        Console.WriteLine("Second array is lexicographically first");
                        break;
                    }
                }
            }
            if (equal ==true)
            {
                if (lenghtOfFirstArray<lenghtOfSecondArray)
                {
                  Console.WriteLine("First array is lexicographically first");  
                }
                else
                {
                    if (lenghtOfFirstArray>lenghtOfSecondArray)
                    {
                        Console.WriteLine("Second array is lexicographically first");
                    }
                    else
                    {
                        Console.WriteLine("The two arrays are lexicographically equal");
                    }
                }
            }
        }
    }
}
